var vm = new Vue({
    el:"#app",
    data(){
        return {
            //费效比
            QFormItem:{
                SaleTotalSum:'',
                SRTotal:'',
                ZCTotal:'',
                ChaE:'',
                FXRateStr:'',
            },

            EditDate: '',
            StoreList: [           //店面
                {
                    value: '东二环店',
                    label: '东二环店'
                },
                {
                    value: '西二环店',
                    label: '西二环店'
                },
                {
                    value: '北二环店',
                    label: '北二环店'
                },
                {
                    value: '建华店',
                    label: '建华店'
                },
                {
                    value: '北杜店',
                    label: '北杜店'
                },
                {
                    value: '金利来店',
                    label: '金利来店'
                },
                {
                    value: '霸州店',
                    label: '霸州店'
                },
                {
                    value: '邢台店',
                    label: '邢台店'
                },
                {
                    value: '运营管理中心',
                    label: '运营管理中心'
                },
            ],
            Store: '',
            ThemeList:[],
            Theme:"",
            TypeList: [                //选择支出/收入
                {
                    value: '收入',
                    label: '收入'
                },
                {
                    value: '支出',
                    label: '支出'
                }
            ],
            Type:'',
            FirstLevelList: [],
            FirstLevel:'',
            SecondLevelList: [],
            SecondLevel:'',
            ThirdLevelList: [],
            ThirdLevel:'',
            //合计金额
            TotalMoney:'',


            //搜索结果
            columns1: [
                {
                    type: 'index',
                    title: '序号',
                    width:46,
                    align: 'center',
                },
                {
                    title: '日期',
                    key: 'EditDate',
                    align: 'center',

                },
                {
                    title: '中心/店面',
                    key: 'Store',
                    align: 'center',
                },
                {
                    title: '活动主题',
                    key: 'Theme',
                    align: 'center',
                },
                {
                    title: '收支类型',
                    key: 'Type',
                    align: 'center',
                },
                {
                    title: '一级项目名称',
                    key: 'ProjectName',
                    align: 'center',
                },
                {
                    title: '二级项目名称',
                    key: 'SecondProjectName',
                    align: 'center',
                },
                {
                    title: '三级项目名称',
                    key: 'ThirdProjectName',
                    align: 'center',
                },
                {
                    title: '金额（元）',
                    key: 'PMoney',
                    align: 'center',
                    width:100
                },

                {
                    title: '录入人',
                    key: 'InputMan',
                    align: 'center',
                }
            ],
            data1: [],

        }
    },
    created(){
        this.initThisPage();
        this.queryFirstLevel();
        this.queryTheme();
    },
    methods:{
        reset(){
            var self = this;
            self.EditDate = "";
            self.Store = "";
            self.Theme = "";
            self.Type = "";
            self.FirstLevel = "";
            self.SecondLevel = "";
            self.ThirdLevel = "";
            self.SecondLevelList = [];
            self.ThirdLevelList = [];
        },
        initThisPage(){
            var self = this;
            $.ajax({
                url: "./goLogin/initIndexPage", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                async:false,
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    if(data.Status==0){
                        // top.location.href = "../../login.html";
                        window.location.href="../../login.html";
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function() {}
            });
        },
        queryTheme(){
            var self = this;
            $.ajax({
                url: "./goProject/queryTheme", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                headers : {
                    'Content-Type' : 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    var ThemeList = data.ThemeList;
                    for(var i=0;i<ThemeList.length;i++){
                        var temp = {
                            value: ThemeList[i].ThemeName,
                            label: ThemeList[i].ThemeName
                        };
                        self.ThemeList.push(temp)
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function(data) {

                }
            });
        },
        querytable(){
            var self = this;
            var info ;
            var EditDate = self.EditDate;
            if(EditDate!=null&&EditDate!=''){
                var tempEditDate = new Date(EditDate);
                EditDate = tempEditDate.toLocaleDateString();
            }
            var Store = self.Store;
            var Theme = self.Theme;
            var Type = self.Type;
            var FirstLevel = self.FirstLevel;
            var SecondLevel = self.SecondLevel;
            var ThirdLevel = self.ThirdLevel;
            var jsondata={"EditDate":EditDate,"Store":Store,"Theme":Theme,"Type":Type,"FirstLevel":FirstLevel,"SecondLevel":SecondLevel,"ThirdLevel":ThirdLevel};
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goProject/queryAllServiceDataInfos", //请求的url地址
                dataType: "json", //返回格式为json
                async:false,
                data: data_json, //参数值
                type: "POST", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                success: function(data) {
                    info = eval(data.ResultList);
                    self.TotalMoney = data.TotalMoney;
                    self.QFormItem.SaleTotalSum = data.SaleTotalSum;
                    self.QFormItem.SRTotal = data.SRTotal;
                    self.QFormItem.ZCTotal = data.ZCTotal;
                    self.QFormItem.ChaE = data.ChaE;
                    self.QFormItem.FXRateStr = data.FXRateStr;
                },
                error: function() {},
            });
            if(info){
                self.data1 = info;
            }
        },
        //查询一级分类
        queryFirstLevel(){
            var self = this;
            $.ajax({
                url: "./goProject/queryFirstLevel", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    var FirstLevelList = new Array();
                    var LevelListJson = data.FirstLevel;
                    for(var i=0;i<LevelListJson.length;i++){
                        var temp = {
                            value: LevelListJson[i].ID,
                            label: LevelListJson[i].title
                        };
                        FirstLevelList.push(temp)
                    }
                    self.FirstLevelList = FirstLevelList;
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function() {}
            });
        },
        //查询二级分类
        querySecondLevel(){
            var self = this;
            var FirstLevel = self.FirstLevel;
            self.SecondLevel = "";
            self.SecondLevelList = [];
            var jsondata = {
                "ID":FirstLevel
            }
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goProject/querySecondLevel", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                type: "POST", //请求方式
                data:data_json,
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    var SecondLevelList = new Array();
                    var LevelListJson = data.SecondLevel;
                    for(var i=0;i<LevelListJson.length;i++){
                        var temp = {
                            value: LevelListJson[i].ID,
                            label: LevelListJson[i].title
                        };
                        SecondLevelList.push(temp)
                    }
                    self.SecondLevelList = SecondLevelList;
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function() {}
            });
        },
        //查询三级分类
        queryThirdLevel(){
            var self = this;
            var SecondLevel = self.SecondLevel;
            self.ThirdLevel = "";
            self.ThirdLevelList = [];
            var jsondata = {
                "ID":SecondLevel
            }
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goProject/querySecondLevel", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                type: "POST", //请求方式
                data:data_json,
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    var ThirdLevelList = new Array();
                    var LevelListJson = data.SecondLevel;
                    for(var i=0;i<LevelListJson.length;i++){
                        var temp = {
                            value: LevelListJson[i].ID,
                            label: LevelListJson[i].title
                        };
                        ThirdLevelList.push(temp)
                    }
                    self.ThirdLevelList = ThirdLevelList;
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function() {}
            });
        },
    }
})







